package com.demo.controller;

import java.util.List;
import java.util.UUID;

import com.demo.bean.TestUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.demo.mapper.UserMapper;

@RestController
public class UserController {

	@Autowired
	private UserMapper mapper;

	@GetMapping("hello")
	public String hello() {
		return "hello";
	}

	@RequestMapping("/select")
	public List<TestUser> select() {
		return mapper.getUser();
	}

	@RequestMapping("/insert")
	public int insert(@RequestBody TestUser testUser) {
		return mapper.insertUser(testUser);
	}

	@RequestMapping("/update")
	public int update(@RequestBody TestUser testUser) {
		return mapper.updateUser(testUser);
	}


	@RequestMapping("/delete/{id}")
	public int delete(@PathVariable("id") String id) {
		return mapper.deleteUserById(id);
	}
}
